﻿using System;
using System.Windows.Forms;
using SQLDiagConfiguration.Properties;

namespace SQLDiagConfiguration
{
    /// <summary>
    /// This class implements the Machine Information specific elements 
    /// of the configuration file
    /// </summary>
    public partial class MachineInfoPage : BasePage
    {
        #region Constructor
        public MachineInfoPage(DiagInfoObject obj)
        {
            DiagInfo = obj;
            InitializeComponent();

        }
        #endregion Constructor

        #region Page specific override methods
        /// <summary>
        /// This override loads the data, then enables / disables the checkboxes
        /// based on the checked state of Event Log Collection checkbox
        /// </summary>
        public override void LoadState()
        {
            base.LoadState();
            bool clicked = chkCollectEventLogs.Checked;
            chkEvtAtStartUp.Enabled = clicked;
            chkEvtAtShutDown.Enabled = clicked;
            chkApplicationLog.Enabled = clicked;
            chkSystemLog.Enabled = clicked;
            chkSecurityLog.Enabled = clicked;

        }
        public override void LoadControlText()
        {
            base.LoadControlText();
            chkCollectEventLogs.Text = Resources.strchkCollectEventLogs;
            chkEvtAtStartUp.Text = Resources.strchkEvtAtStartUp;
            chkEvtAtShutDown.Text = Resources.strchkEvtAtShutDown;
            chkApplicationLog.Text = Resources.strchkApplicationLog;
            chkSecurityLog.Text = Resources.strchkSecurityLog;
            chkSystemLog.Text = Resources.strchkSystemLog;
        }
        #endregion Page specific override methods

        #region Event Handlers
        /// <summary>
        /// This event handler is responsible for enabling / disabling check boxes
        /// base on the value of the Event Log Collection checkbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chkCollectEventLogs_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox cb = ((CheckBox)sender);
            bool clicked = cb.Checked;
            chkEvtAtStartUp.Enabled = clicked;
            chkEvtAtShutDown.Enabled = clicked;
            chkApplicationLog.Enabled = clicked;
            chkSystemLog.Enabled = clicked;
            chkSecurityLog.Enabled = clicked;
        }
        #endregion Event Handlers
    }
}
